//
//  WelcomeViewController.m
//  VTravel
//
//  Created by lanouhn on 16/8/1.
//  Copyright © 2016年 xiaoYu. All rights reserved.
//

#import "WelcomeViewController.h"
#import "LaunchViewController.h"

@interface WelcomeViewController ()


@end

@implementation WelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self creatScrollView];
}

#pragma mark - 
- (void)creatScrollView{
    
    NSArray *imageArray = @[@"guide_home", @"guide_steward_shop"];

    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    scrollView.pagingEnabled = YES;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.contentSize = CGSizeMake(kScreenWidth * imageArray.count, kScreenHeight);
    
    for (int i = 0; i < imageArray.count;i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth * i, 0, kScreenWidth, kScreenHeight)];
        imageView.image = [UIImage imageNamed:imageArray[1]];
        
        if (i == imageArray.count - 1) {
            imageView.userInteractionEnabled = YES;
            [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(easeInHomeVC)]];
        }
        [scrollView addSubview:imageView];
    }
    [self.view addSubview:scrollView];
}
#pragma mark - 实现手势方法
- (void)easeInHomeVC{
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:isFirstLaunch];
    LaunchViewController *launchVC = [[LaunchViewController alloc] initWithNibName:@"LaunchViewController" bundle:nil];
    [UIApplication sharedApplication].keyWindow.rootViewController = launchVC;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
